<?php
$field_arr = $_POST['info'];
$menu_arr = $_POST['menu'];
$id = $field_arr['id'];
$arr = array('id');
$field_arr = arr_diff($field_arr, $arr);
$field_arr = empty2zero($field_arr, array('sort'));
$menu_id = implode(',', $menu_arr);
$menuarr = sel_arr_sql($menu, "*", "id in(" . $menu_id . ")");
// 插入用户组名称
if ($id == '') {
	$field_arr["status"] = 1;
	$role_id = insert_one_sql($role, $field_arr, 0);
	admin_log('新增权限组');
} else {
	update_sql($role, $field_arr, "id=$id", 0, 0);
	admin_log('修改权限组');
	$role_id = $id;
} 
delete_sql($access, "role_id=" . $role_id);
foreach($menuarr as $key => $menu) {
	$data['role_id'] = $role_id;
	$data['menu_id'] = $menu['id'];
	$data['parentid'] = $menu['parentid'];
	insert_one_sql($access, $data, 0, 1);
} 
echo alert('授权成功', 'admin.php?act=qxlist');

?>
